import { defineStore } from 'pinia'
import {ref} from "vue";
import {UserType} from "@/models/user";
import {getCurrentUser} from "@/api/user.ts";


export const userStatesStore = defineStore('user', () => {
    const userInfo = ref<UserType | null>()
    const getUserInfo = async () => {
        const res = await getCurrentUser()
        userInfo.value = res.data.data
    }
    const clearUserInfo = async () => {
        userInfo.value = null
    }
    return {
        userInfo,
        getUserInfo,
        clearUserInfo
    }
},{
    persist:true
})